{
  "nbformat": 4,
  "nbformat_minor": 0,
  "metadata": {
    "colab": {
      "name": "frequently_used_piece.ipynb",
      "provenance": [],
      "include_colab_link": true
    },
    "kernelspec": {
      "name": "python3",
      "display_name": "Python 3"
    }
  },
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "view-in-github",
        "colab_type": "text"
      },
      "source": [
        "<a href=\"https://colab.research.google.com/github/yananma/useful_program/blob/master/DL/PyTorch/frequently_used_piece.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "4IMPeTnw_yfS",
        "colab_type": "text"
      },
      "source": [
        "## 尽量是有共性的，少用只有这一个程序用的，往上摞\n",
        "\n"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "m5HV-OiWxkUp",
        "colab_type": "text"
      },
      "source": [
        "### MxNet fashion mnist\n",
        "\n",
        "\n"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "J7Q49WHhx8Q4",
        "colab_type": "code",
        "colab": {}
      },
      "source": [
        "for X, y in test_iter:\n",
        "    break\n",
        "\n",
        "true_labels = d2l.get_fashion_mnist_labels(y.asnumpy())\n",
        "pred_labels = d2l.get_fashion_mnist_labels(net(X).argmax(axis=1).asnumpy())\n",
        "titles = [true + '\\n' + pred for true, pred in zip(true_labels, pred_labels)]\n",
        "\n",
        "d2l.show_fashion_mnist(X[0:9], titles[0:9])"
      ],
      "execution_count": 0,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "Nh9FYHrMIl0t",
        "colab_type": "code",
        "colab": {}
      },
      "source": [
        "import numpy as np \n",
        "import pandas as pd \n",
        "import matplotlib.pyplot as plt \n",
        "import torch \n",
        "import torch.nn as nn \n",
        "import torchvision \n",
        "import torchvision.transforms as transforms "
      ],
      "execution_count": 0,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "bWQNVPNM-0VO",
        "colab_type": "text"
      },
      "source": [
        "### PyTorch tutorial MNIST "
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "XYFEAO_I-YSZ",
        "colab_type": "code",
        "colab": {}
      },
      "source": [
        "# MNIST dataset \n",
        "train_dataset = torchvision.datasets.MNIST(root='./data', train=True, transform=transforms.ToTensor(), download=True)\n",
        "test_dataset = torchvision.datasets.MNIST(root='./data', train=False, transform=transforms.ToTensor())\n",
        "\n",
        "# Data loader\n",
        "train_loader = torch.utils.data.DataLoader(dataset=train_dataset, batch_size=batch_size, shuffle=True)\n",
        "test_loader = torch.utils.data.DataLoader(dataset=test_dataset, batch_size=batch_size, shuffle=False)"
      ],
      "execution_count": 0,
      "outputs": []
    }
  ]
}